{% extends 'layout.html' %}

{% block body %}
    <!-- Page Header -->
    <header class="masthead" style="background-image: url('{{ url_for('static', filename='images/home-bg.jpg') }}')">
      <div class="overlay"></div>
      <div class="container">
        <div class="row">
          <div class="col-lg-8 col-md-10 mx-auto">
            <div class="site-heading">
              <h1>嘟嘟生活记录专用</h1>
              <span class="subheading">多多进来看一看的！</span>
            </div>
          </div>
        </div>
      </div>
    </header>
  {% if not articles %}
    <div style="margin:100px;text-align:center" >
      <h4>该页面文章不存在哦！</h4>
    </div>
  {% else %}
  <div class="container content">
    {% for article in articles %}
      <article class="post-preview">
        <h1 class="post-title">{{article.title}}</h1>
        <p class="post-author">作者：{{article.author}} &nbsp {{article.create_date}} </p>
        <div class="clearfix">
        <a class="btn btn-primary float-right" href="article/{{article.id}}">查看全文 →</a>
        </div>
      </article>
      <hr class="underline">
    {% endfor %}
    </div>
    {% endif %}
    <ul class="pagination justify-content-center mb-4">
      {% if page == 1 %}
        <li class="page-item disabled">
            <a class="page-link" href="/index?page={page-1}">← 上一页</a>
        </li>
      {% else %}
        <li>
            <a class="page-link" href="/?page={{page-1}}">← 下一页</a>
        </li>
      {% endif %}
        <li class="page-item">
          <a class="page-link" href="/?page={{page+1}}">下一页 →</a>
        </li>
      </ul>
{% endblock %}
